#include "Process.h"

#define PROBAR '='
#define LENBAR 101
// 进度条
//void ProBar(){
//    char Bar[101];
//    int cnt = 0;
//    int len = sizeof(Bar);
//    memset(Bar,'\0',sizeof(Bar));
//    char circle[] = "/-\\|";
//    while(cnt <= len - 1){
//        printf("[%-100s][%02d%%][%c]\r",Bar,cnt,circle[cnt%4]);
//        fflush(stdout);
//        Bar[cnt++] = PROBAR;
//        usleep(20000); 
//    }
//    printf("\n");
//}

void ProBar(double total, double current){
    char Bar[101];
    int cnt = 0;
    memset(Bar,'\0',sizeof(Bar));
    char circle[] = "/-\\|";
    double rate = (current*100)/total;
    int LoopNum = (int)rate;
    while(cnt < LoopNum){
        Bar[cnt++] = PROBAR;     
    }
    printf("[%-100s][%.1lf%%][%c]\r",Bar,rate,circle[LoopNum%4]);
    usleep(50000);
    fflush(stdout);
}
//void ProBarv2(double tatol, double finish){
//
//} 
